<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
if (!function_exists("jsScript")){
	function jsScript($text){
		return "<script type=\"text/javascript\">\n/*<![CDATA[*/\n{$text}\n/*]]>*/\n</script>";
	}
}

if (!function_exists("jsFile")){
	function jsFile($url){
		return '<script type="text/javascript" src="'.htmlEncode($url).'"></script>';
	}
}

if (!function_exists("htmlEncode")){
	function htmlEncode($text){
		return htmlspecialchars($text,ENT_QUOTES,"UTF-8");
	}
}

if (!function_exists("htmlDecode")){
	function htmlDecode($text){
		return htmlspecialchars_decode($text,ENT_QUOTES);
	}
}

if (!function_exists("add_button_html")){
	function add_button_html(){
		
	}
}
if(! function_exists('radiolist')){
   function radiolist($name,$arr,$idtag = false,$selected = '',$js=''){
		$html = '';
		$i = 0;
		foreach ($arr as $key=>$text){
			$html .= '<input type="radio" class="radio" name = "'.$name.'" value="'.$key.'"'.$js;
			if ($idtag){
				$html .= ' id ="'.$name.'_'.$key.'" ';
			}
			if ($key == $selected && $selected != ''){
				$html .= ' checked="checked"';
			}
			$html .= ' />'."\n";
			$html .= '<label for="'.$name.'_'.$key.'">'.$text.'</label>'."\n";
		}
		return $html;
	}
}

if(!function_exists('selectlist')){
	function selectlist($name,$lable = '',$options,$idtag = false,$selected = '',$js=''){
		$html = '';
		if ($lable != ''){
			$html .='<lable for="'.$name.'" class="lable">'.$lable.'</lable>'."\n";
		}
		$html .='<select class="input select" name="'.$name.'"';
		if ($idtag){
			$html .=' id="'.$name.'" ';
		}
		$html .= $js.' >'."\n";
		foreach ($options as $key=>$text){
			$html .='<option value = "'.$key.'"';
			if($key == $selected && $selected != ''){
				$html .=' selected="selected" ';
			}
			$html .='>'.$text.'</option>'."\n";
		}
		$html .='</select>'."\n";
		return $html;
	}
}